<?php


class Defined_Plugin_LanguageHandler
	extends Zend_Controller_Plugin_Abstract{
		
	public function routeShutdown(Zend_Controller_Request_Abstract $request){
		$sCurrentRouter=Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName();	
		Zend_Registry::set('CurrentRoute',$sCurrentRouter);
	}
	
	public function routeStartup(Zend_Controller_Request_Abstract $request){
		$this->callLanguage();
	 	Zend_Form::setDefaultTranslator(Zend_Registry::get('Zend_Translate')); 
		Defined_RouterControl::defineRoute();
		
	 	/*
	 	// TRANSLATE SEGMENT
	 	// Set language to global param so that our language route can
        // fetch it nicely. 
        $front = Zend_Controller_Front::getInstance();
        $router = $front->getRouter();
        $oLocale=Zend_Registry::get('Zend_Locale');
        $router->setGlobalParam('lang', $oLocale->getLanguage());
        */	
	 	
	}
		 
	function callLanguage(){
		# start setup language
		$oLang=LoadObject::startLanguage();
		$sLang=$this->getRequest()->language;
		# set language by request
		$oLang->install($sLang);
		# set zend register to translator
		$oLang->load();
		
	}		
}
